package yf.platform.dao;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.ICallback;
import org.mybatis.spring.SqlSessionTemplate;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * Created by Yfsoft on 2016/8/18.
 */
public class JfinalDaoSupport implements DaoSupport{

    @Override
    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {

    }

    @Override
    public List desc(String table) {
        return Db.find("show full fields from ?",table);
    }

    @Override
    public List table() {
        return Db.find("SHOW TABLE STATUS  where Name not in (SELECT m_view FROM sys_model)");
    }

    @Override
    public void beginTransaction() {

    }

    @Override
    public void commit() {

    }

    @Override
    public void runScript(String path) throws IOException {

    }

    @Override
    public void rollback() {

    }

    @Override
    public int execute(String sql) {
        return Db.update(sql);
    }

    @Override
    public <T> int insert(T e, String id) {
//        return Db.save()
        return 0;
    }

    @Override
    public int insert(String table_name, Map... es) {
        return 0;
    }

    @Override
    public int delete(String table, String condition) {
        return 0;
    }

    @Override
    public <T> int update(String id, T e) {
        return 0;
    }

    @Override
    public int update(Map<String, String> e, String condition, String table) {
        return 0;
    }

    @Override
    public <T> T findOne(String id, Object param) {
        return null;
    }

    @Override
    public <T> T findOne(String table_name, String fields, String condition) {
        return null;
    }

    @Override
    public List find(String id, Object param) {
//        return Db.find(
        return null;
    }

    @Override
    public List find(String sql) {
        return Db.find(sql);
    }

    @Override
    public List find(String table_name, String fields, String condition, String order) {
        return Db.find("select " + fields + " from " + table_name + "where 1 =1 and " + condition + " order by " + order);
    }

    @Override
    public List findByPage(String id, Object param, int page, int max) {
        return null;
    }

    @Override
    public List findByPage(String table_name, String fields, String condition, String orderint, int page, int max) {
        return null;
    }

    @Override
    public List injoin(String tables, String fields, String condition, String order) {
        return null;
    }

    @Override
    public List injoin(String tables, String fields, String condition, String order, int max, int page) {
        return null;
    }
}
